<template>
  <div>
    <a-spin :spinning="loading">
      <a-form :form="form">
        <a-row>
          <a-col span="12">
            <a-form-item
              label="用户账号"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
            >
              <a-input
                placeholder="请输入用户账号"
                :disabled="true"
                v-model="userInfos.userNameId"
              />
            </a-form-item>
          </a-col>
          <!-- <a-col span="12">
            <a-form-item label="入职时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
              <t-date style="width:100%;" showTime :disabled="true" dateFormat="YYYY-MM-DD HH:mm:ss"
                v-decorator="['userEntryTime']" placeholder="入职时间">
              </t-date>
            </a-form-item>
          </a-col> -->
        </a-row>
        <!-- <a-row>
          <a-col span="12">
            <a-form-item
              label="最后登录时间"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
            >
              <t-date
                style="width:100%;"
                showTime
                :disabled="true"
                dateFormat="YYYY-MM-DD HH:mm:ss"
                v-decorator="['lastLogTime']"
                placeholder="最后登录时间"
              >
              </t-date>
            </a-form-item>
          </a-col>
          <a-col span="12">
            <a-form-item
              label="最后登录IP"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
            >
              <a-input
                placeholder="最后登录IP"
                :disabled="true"
                v-decorator="['lastLogIp']"
              />
            </a-form-item>
          </a-col>
        </a-row> -->
        <a-row>
          <a-col span="12">
            <a-form-item
              label="状态"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
            >
              <t-dict-select-tag
                type="select"
                dictCode="UserInfoStatus"
                :disabled="true"
                placeholder="状态"
                v-model="userInfos.userStatus"
              />
              <!-- v-decorator="['userStatus']" -->
            </a-form-item>
          </a-col>
        </a-row>
        <a-form-item class="hiddenItem">
          <a-input v-decorator="['uuid']" disabled type="hidden" />
        </a-form-item>
      </a-form>
    </a-spin>
  </div>
</template>

<script>
import pick from "lodash.pick";
import TreeSelect from "@/components/TopVUI/custom/TreeSelect";
import { TDictSelectTag } from "@/components";
// 表单字段
const fields = [
  "uuid",
  "userName",
  "userNameId",
  "userEntryTime",
  "userStatus",
  "userSort",
  "lastLogTime",
  "lastLogIp",
];
export default {
  props: {
    loading: {
      type: Boolean,
      default: () => false,
    },
    userInfos: {
      type: Object,
      default: () => null,
    },
  },
  components: {
    TreeSelect,
    TDictSelectTag,
  },
  watch: {
    userInfos: {
      handler(val) {},
      immediate: true,
    },
  },
  data() {
    return {
      title: "用户信息",
      labelCol: {
        xs: {
          span: 24,
        },
        sm: {
          span: 6,
        },
      },
      wrapperCol: {
        xs: {
          span: 24,
        },
        sm: {
          span: 18,
        },
      },
      form: this.$form.createForm(this),
    };
  },
  created() {
    // 防止表单未注册
    fields.forEach((v) => this.form.getFieldDecorator(v));
    this.$watch("userInfos", () => {
      this.userInfos && this.form.setFieldsValue(pick(this.userInfos, fields));
    });
  },
  methods: {},
};
</script>
